import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';


export default {
    /**
     * mock bootstrap
     */
    bootstrap() {
        let mock = new MockAdapter(axios, { delayResponse: 1000 });

        // mock success request
        mock.onPost('/project/selectProjects.do').reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                "projects": [{
                    "projectName": "项目1",
                    "projectType": "0",
                    "status": 1,
                    "projectStartDate": "2017-12-28",

                }],
                "page": {
                    currentPage: 1,
                    pageNumber: 10
                }
            }
        });

        // mock error request
        mock.onGet('/error').reply(500, {
            msg: 'failure'
        });

        mock.onPost("/sso/login.do", {
            userName: "123",
            userPass: '123'
        }).reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                userInfo: {
                    "userName": "顾章华123",
                    "userType": "1",
                },
                menu: [{
                    key: "project",
                    children: [{
                        key: "pro",
                    }, {
                        key: "home"
                    }]

                }]
            }
        });

        mock.onPost("/sso/getUserInfo.do", {}).reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {

                "userName": "顾章华123",
                "userType": "1",
                "imgUrl": "/asdasd/"
            }
        });

        mock.onPost("/sso/getMenu.do", ).reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": [{
                key: "project",
                children: [{
                    key: "home",
                }, {
                    key: "pro",
                }]

            }, {
                key: "work",
                children: [{
                    key: "home",
                }, {
                    key: "attendance",
                }]

            }, {
                key: "system",
                children: [{
                    key: "home",
                }, {
                    key: "privilege",
                }, {
                    key: "role",
                }, {
                    key: "staff",
                }, {
                    key: "department",
                }, {
                    key: "bulletin",
                }]

            }]
        });
        /* 
            项目详情页

        */
        mock.onPost("/project/getProjectDetailById.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                "id": '124',
                "name": "先声",
                'customer': "客户名称",
                'acceptDate': "承接日期",
                'acceptName': "承接人",
                'quotationNo': "报价单编号",
                'projectType': "项目类型",
                'workloadType': "工作量类型",
                'workload': "工作量",
                'workloadTotal': "总价",
                'conductor': "处理人",
                'startdate': "项目开始时间",
                'enddate': "项目结束时间",
                'payment': false, //是否付款
                'paymentNum': 1000000, //付款金额
                'pact': false, //是否有合同
                'explain': '项目概述', //项目概述
                'stage': 1, //项目阶段
                'state': '项目状态', //项目状态
                'creator': '创建人id', //创建人id
                'phone': '电话', //电话
                "members": [{
                    id: 123,
                    name: "顾章华",
                    avator: "https://www.njyjz.com/console/img/defult-people.png"
                }, {
                    id: 124,
                    name: "顾章华2",
                    avator: "https://www.njyjz.com/console/img/defult-people.png"
                }],

                "tasks": [{
                    id: 123,
                    name: "任务名称1",
                    createdate: "2011-11-11 11:11:11",
                    enddate: "完成时间"
                }],
                milestones: [{
                    id: 124,
                    name: "里程碑1",
                    enddate: "计划完成时间"
                }],
                bulletions: [{
                    id: 124,
                    name: "简报1",
                    startdate: "计划完成时间",
                    enddate: "结束时间"
                }],
                attachments: [{
                    id: 124,
                    name: "文件1",
                    url: '',
                    createUserName: "顾章华",
                    createDate: "2011-11-11 11:11:11"
                }, {
                    id: 123,
                    name: "文件21",
                    url: '',
                    createUserName: "顾章华",
                    createDate: "2011-11-11 11:11:11"
                }]
            }
        });


        /* 
        
            任务相关
        */
        mock.onPost("/task/getTaskByProjectId.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": [{
                id: 1,
                name: "待处理",
                rank: 1,
                children: [{
                    id: 12,
                    rank: 1,
                    name: "任务11",
                    startdate: "2011-11-11",
                    enddate: "2011-11-12",
                    work: 12.2

                }, {
                    id: 13,
                    rank: 2,
                    name: "任务12",
                    startdate: "2011-11-11",
                    enddate: "2011-11-12",
                    work: 12.2

                }]
            }, {
                id: 2,
                name: "处理中",
                rank: 2,
                children: [{
                    id: 14,
                    rank: 1,
                    name: "任务21",
                    startdate: "2011-11-11",
                    enddate: "2011-11-12",
                    work: 12.2

                }, {
                    id: 15,
                    rank: 2,
                    name: "任务22",
                    startdate: "2011-11-11",
                    enddate: "2011-11-12",
                    work: 12.2

                }]
            }]
        });












        mock.onPost("/project/getProjectTasksById.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": [{
                id: 123,
                name: "任务名称1",
                leader: "负责人1",
                status: "进行中",
                'rank': "紧急",
                createdate: "2011-11-11 11:11:11",
                enddate: "2011-11-11 11:11:11",
                finishdate: "2011-11-11 11:11:11",

            }, {
                id: 124,
                name: "任务名称2",
                leader: "负责人2",
                status: "进行中",
                'rank': "紧急",
                createdate: "2011-11-11 11:11:11",
                enddate: "2011-11-11 11:11:11",
                finishdate: "2011-11-11 11:11:11",

            }]
        });
        /* 
            权限相关
        */
        mock.onPost("/user/privilege/getPrivilegeTotal.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": [{
                id: 1,
                privilegeName: "页面权限1",
                privilegeExplain: "说明", //用户名
                privilegeType: 0, //用户名

            }, {
                id: 2,
                privilegeName: "薪资权限1",
                privilegeExplain: "说明", //用户名
                privilegeType: 1, //用户名

            }, {
                id: 3,
                privilegeName: "页面权限2",
                privilegeExplain: "说明", //用户名
                privilegeType: 0, //用户名

            }, {
                id: 4,
                privilegeName: "薪资权限2",
                privilegeExplain: "说明", //用户名
                privilegeType: 1, //用户名

            }, {
                id: 5,
                privilegeName: "薪资权限3",
                privilegeExplain: "说明", //用户名
                privilegeType: 1, //用户名

            }]
        });

        /* 
            角色相关
        */
        mock.onPost("/user/role/getRolesByName.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                roles: [{
                    id: 1,
                    roleName: "角色去1",
                    roleExplain: "说明", //用户名

                }, {
                    id: 1,
                    roleName: "角色去2",
                    roleExplain: "说明", //用户名

                }],
                page: {
                    currentPage: 1,
                    dbIndex: 1,
                    dbNumber: 10,
                    totalPage: 10,
                    totalNumber: 100,
                    pageNumber: 10
                }
            }
        });
        // 根绝id查询角色数据
        mock.onPost("/user/role/getRolesById.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                id: 1,
                roleName: "角色去1",
                roleExplain: "说明", //用户名
                privilegeIds: [1, 2]
            }

        });

        // 新建一个角色
        mock.onPost("/user/role/createRole.do", {
            // roleName: "",
            // roleExplain: "", //用户名
        }).reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                id: 123,
                roleName: "角色去1",
                roleExplain: "说明", //用户名
                privilegeIds: []
            }

        });

        // 新建一个角色
        mock.onPost("/user/role/modifyRole.do", {
            // roleName: "",
            // roleExplain: "", //用户名
        }).reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                id: 123,
                roleName: "角色去1",
                roleExplain: "说明", //用户名
                privilegeIds: []
            }

        });

        /* 
            部门有关
        
        */
        mock.onPost("/user/department/getDepartment.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": [{
                id: 100,
                name: "易杰智科技",
                grade: 0,
                amount: '33',
                parentId: '0',
            }, {
                id: 101,
                name: "研发部",
                grade: 1,
                amount: '14',
                parentId: 100,
            }, {
                id: 103,
                name: "前端",
                grade: 2,
                amount: '4',
                parentId: 101,
            }, {
                id: 104,
                name: "后台",
                grade: 2,
                amount: '4',
                parentId: 101,
            }, {
                id: 102,
                name: "本地化部",
                grade: 1,
                amount: '29',
                parentId: 100,
            }]
        });

        mock.onPost("/user/department/getDepartmentList.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": [{
                id: 100,
                name: "易杰智科技",
                grade: 0,
                amount: '33',
                parentId: '0',
            }, {
                id: 101,
                name: "研发部",
                grade: 1,
                amount: '14',
                parentId: 100,
            }, {
                id: 103,
                name: "前端",
                grade: 2,
                amount: '4',
                parentId: 101,
            }, {
                id: 104,
                name: "后台",
                grade: 2,
                amount: '4',
                parentId: 101,
            }, {
                id: 102,
                name: "本地化部",
                grade: 1,
                amount: '29',
                parentId: 100,
            }]
        });


        /* 
            员工有关
        
        */
        mock.onPost("/user/getStaffList.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                staffs: [{
                    id: 1,
                    userUserName: "顾章华",
                    userName: "用户名", //用户名
                    userSalay: '基本薪资', //基本薪资
                    userSex: '0', //性别
                    userAge: '年龄', //年龄
                    userSex: 0,
                    userDuty: '职务',
                    userDepartment: '部门',
                    userPhone: '联系方式'
                }, {
                    id: 2,
                    userUserName: "顾章华1",
                    userSex: 1,
                    userDuty: '职务',
                    userDepartment: '部门',
                    userPhone: '联系方式'
                }],
                page: {
                    currentPage: 1,
                    dbIndex: 1,
                    dbNumber: 10,
                    totalPage: 10,
                    totalNumber: 100,
                    pageNumber: 10
                }
            }
        });
        mock.onPost("/user/getStaffById.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {
                id: 1,
                userUsername: "顾章华",
                userName: "用户名", //用户名
                userSalay: '基本薪资', //基本薪资
                userSex: '0', //性别
                userAge: '年龄', //年龄
                userSex: 0,
                userDuty: '职务',
                userDepartment: '部门',
                userPhone: '联系方式'

            }
        });

        mock.onPost("/user/newStaff.do").reply(200, {
            "respCode": "0",
            "respMsg": "success",
            "result": {

            }
        });

    }
};